/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iwords.ejb;

import com.iwords.service.object.TeacherEntity;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author sunmellon
 */
@Stateless
public class TeacherEntityFacade extends AbstractFacade<TeacherEntity> {
    @PersistenceContext(unitName = "iwords")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public TeacherEntityFacade() {
        super(TeacherEntity.class);
    }
    
    public TeacherEntity findByName(String teachername){
        System.out.println("TeacherEntityFacade.findByname() teachername= "+teachername);
        TeacherEntity teacher = (TeacherEntity)getEntityManager().createQuery("SELECT i FROM TeacherEntity i WHERE i.teachername = :teachername").setParameter("teachername", teachername).getSingleResult();
        //System.out.println("TeacherEntityFacade.findByname() teacher.getStudents()="+teacher.getStudents());
        return teacher;
    }
}
